//
//  HJDNameViewController.m
//  JYHospital
//
//  Created by 胡金东 on 16/6/15.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDNameViewController.h"
#import "AFNetworking.h"
@interface HJDNameViewController ()

@end

@implementation HJDNameViewController

//-(void)viewWillAppear:(BOOL)animated
//{
//    
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor getColorWithHexNumber:@"CFCFCF"];
    self.title = @"名字";
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19],
      NSForegroundColorAttributeName:[UIColor getColorWithHexNumber:@"848484"]}];
    
    UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftBtn setTitle:@"取消" forState:UIControlStateNormal];
    [leftBtn setTitleColor:[UIColor getColorWithHexNumber:@"848484"] forState:UIControlStateNormal];
    [leftBtn sizeToFit];
    [leftBtn addTarget:self action:@selector(backItemClick) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
        self.navigationItem.leftBarButtonItem = leftItem;
    
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [rightBtn setTitle:@"保存" forState:UIControlStateNormal];
    [rightBtn setTitleColor:[UIColor getColorWithHexNumber:@"5CC6AB"] forState:UIControlStateNormal];
    [rightBtn sizeToFit];
    [rightBtn addTarget:self action:@selector(saveItemClick) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
    self.navigationItem.rightBarButtonItem = rightItem;

    [self setUpText];

    //添加手势
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
    tap.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:tap];
    
}

//隐藏键盘
-(void)viewTapped:(UITapGestureRecognizer*)tap
{
    
    [self.view endEditing:YES];
    
}


-(void)backItemClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)saveItemClick{
    
    NSString *url = @"/app/modifyUser.do";
    NSString *path = [Hurl stringByAppendingString:url];
    AFHTTPSessionManager *mgr = [AFHTTPSessionManager manager];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
//    params[@"nickName"] = 
    
    HJDLog(@"点击保存");
}
-(void)setUpText{
    
    UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(0, HJDVerticalMargin + HJDNavigHeight, HJDWidth, 50)];
    text.backgroundColor = [UIColor whiteColor];
    text.text = @"纳兰古月啊";
    text.clearButtonMode = UITextFieldViewModeAlways;
    [self.view addSubview:text];
}

@end
